package cemp.controller;

import cemp.common.dto.Response;
import cemp.dto.ro.WxLoginResponseDto;
import cemp.enums.MessageEnum;
import cemp.service.WxAuthService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author xshibai
 * @date 2025年07月25日 15:23
 */
@RestController
@AllArgsConstructor
@RequestMapping("/wx/login")
public class WxLoginController {

    @Autowired
    WxAuthService wxAuthService;


    @GetMapping("/code2session")
    public Response<WxLoginResponseDto> code2session(@RequestParam("jsCode") String jsCode) {
        return Response.success(wxAuthService.code2Session(jsCode));
    }

    @GetMapping("/msg/send")
    public Response<WxLoginResponseDto> sendMsg(@RequestParam("openid") String openid) {
        //todo openid => params
        Map<String,Object> miniParams = new HashMap<>();
        miniParams.put("thing2", "点击立即签到");
        miniParams.put("name3", "徐世白");
        wxAuthService.sendWxMessage(openid,miniParams, MessageEnum.COME_NOTIFY.getCode());
        return Response.success();
    }

//    @GetMapping("/msg/task/inform/send")
//    public Response<WxLoginResponseDto> sendMsg2(@RequestParam("openid") String openid) {
//        //todo openid => params
//        Map<String,Object> miniParams = new HashMap<>();
//        miniParams.put("thing9", "点击立即签到");
//        miniParams.put("thing11", "徐世白");
//        wxAuthService.sendWxMessage(openid,miniParams, MessageEnum.COME_NOTIFY.getCode());
//        return Response.success();
//    }
}
